using Services;
using UnityEngine;

[RequireComponent(typeof(Animator))]
public class DoppelgangerAnimator : CharacterAnimator
{
    protected MoveChecker moveChecker;
    protected EventSystem eventSystem;

    protected override void Awake()
    {
        base.Awake();
        eventSystem = ServiceLocator.Get<EventSystem>();
        moveChecker = new MoveChecker(transform);
    }

    protected override void Update()
    {
        base.Update();
        if (moveChecker.Moved)
        {
            TrySetMotion(ECharacterMotion.Move);
            Face = EDirectionTool.NearestDirection4(moveChecker.Direction).ToEDirection();
        }
        else
            TrySetMotion(ECharacterMotion.Idle);
    }

    private void OnDestroy()
    {
        moveChecker.Active = false;
    }
}
